﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ITMan
{
    public partial class FormMain : RibbonForm
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void ribbonOrbMenuItemCloseAll_Click(object sender, EventArgs e)
        {
            while (this.ActiveMdiChild != null)
            {
                this.ActiveMdiChild.Close();
            }
        }

        private void ribbonOrbOptionButtonExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ribbonButtonPlat_Click(object sender, EventArgs e)
        {
            FormPlat mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormPlat)
                {
                    mr = (FormPlat)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormPlat();
                mr.MdiParent = FormPlat.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonImc_Click(object sender, EventArgs e)
        {
            FormUser mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormUser)
                {
                    mr = (FormUser)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormUser();
                mr.MdiParent = FormUser.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonFailure_Click(object sender, EventArgs e)
        {
            FormQueryAuthFall mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormQueryAuthFall)
                {
                    mr = (FormQueryAuthFall)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormQueryAuthFall();
                mr.MdiParent = FormQueryAuthFall.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonOnline_Click(object sender, EventArgs e)
        {
            FormQueryOnlineUser mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormQueryOnlineUser)
                {
                    mr = (FormQueryOnlineUser)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormQueryOnlineUser();
                mr.MdiParent = FormQueryOnlineUser.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonSync_Click(object sender, EventArgs e)
        {
            FormDPSync mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormDPSync)
                {
                    mr = (FormDPSync)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormDPSync();
                mr.MdiParent = FormDPSync.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonHostSetting_Click(object sender, EventArgs e)
        {
            FormVmSet mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormVmSet)
                {
                    mr = (FormVmSet)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormVmSet();
                mr.MdiParent = FormVmSet.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonVmList_Click(object sender, EventArgs e)
        {
            FormVMList mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormVMList)
                {
                    mr = (FormVMList)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormVMList();
                mr.MdiParent = FormVMList.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonCheckNodeLink_Click(object sender, EventArgs e)
        {
            FormCheckNodeLink mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormCheckNodeLink)
                {
                    mr = (FormCheckNodeLink)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormCheckNodeLink();
                mr.MdiParent = FormCheckNodeLink.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }

        private void ribbonButtonWorkTrack_Click(object sender, EventArgs e)
        {

        }

        private void ribbonPanel3_ButtonMoreClick(object sender, EventArgs e)
        {
            MessageBox.Show("是否长期使用，尚未明确！");
        }

        private void ribbonButtonOrgs_Click(object sender, EventArgs e)
        {
            FormOrgs mr = null;
            foreach (Form ftmp in this.MdiChildren)
            {
                if (ftmp is FormOrgs)
                {
                    mr = (FormOrgs)(ftmp);
                    break;
                }
            }
            if (mr == null || mr.Disposing)
            {
                mr = new FormOrgs();
                mr.MdiParent = FormOrgs.ActiveForm;
                mr.WindowState = FormWindowState.Maximized;
            }
            this.ActivateMdiChild(mr);
            mr.WindowState = FormWindowState.Maximized;
            mr.Show();
            mr.Activate();
        }
        



    }
}
